package com.xiaozhen.common.core.domain.app;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.xiaozhen.common.core.domain.BaseEntity;
import com.xiaozhen.common.core.utils.DateUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * HISTORY
 *
 * @author zhenweisheng
 * @date 2021/9/24 16:10
 * @description:
 */
@Data
@TableName("oauth_client_details")
@ApiModel(description = "客户端授权管理的表")
public class OauthClientDetails {

    @TableId
    @ApiModelProperty(value = "客户端ID")
    private String clientId;

    @ApiModelProperty(value = "能访问的资源id集合（没设置，就是对所有的Resource Server都有访问权限）")
    private String resourceIds;

    @TableField(select = false)
    @ApiModelProperty(value = "客户端密码")
    private String clientSecret;

    @ApiModelProperty(value = "授权范围")
    private String scope;

    @ApiModelProperty(value = "授权方式")
    private String authorizedGrantTypes;

    @ApiModelProperty(value = "授权中心接受或拒绝请求后的跳转网址")
    private String webServerRedirectUri;

    @ApiModelProperty(value = "client自己的权限设置,不能为空")
    private String authorities;

    @ApiModelProperty(value = "access_token过期时间，秒")
    private Integer accessTokenValidity;

    @ApiModelProperty(value = "refresh_token过期时间，秒")
    private Integer refreshTokenValidity;

    @ApiModelProperty(value = "预留的字段,在Oauth的流程中没有实际的使用,可选,但若设置值,必须是JSON格式的数据，在实际应用中, 可以用该字段来存储关于客户端的一些其他信息")
    private String additionalInformation;

    @ApiModelProperty(value = "用户是否自动Approval操作, 默认值为 'false'")
    private String autoapprove;

    @TableLogic
    @ApiModelProperty(value = "删除标识（0-正常,1-删除）")
    private Integer delFlag;

    /**
     * 创建者
     */
    @ApiModelProperty(value = "创建者")
    @TableField(fill = FieldFill.INSERT)
    private Long createBy;

    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间")
    @TableField(fill = FieldFill.INSERT)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonFormat(shape = JsonFormat.Shape.STRING, timezone = "GMT+8",pattern = DateUtils.YMDHMS1)
    private LocalDateTime createTime;

    /**
     * 更新者
     */
    @ApiModelProperty(value = "更新者")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Long updateBy;

    /**
     * 更新时间
     */
    @ApiModelProperty(value = "更新时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonFormat(shape = JsonFormat.Shape.STRING, timezone = "GMT+8",pattern = DateUtils.YMDHMS1)
    private LocalDateTime updateTime;
}
